# 定义
# way-01
my_dict1=dict()
print(type(my_dict1),my_dict1)
# way-02
my_dict2={}
print(type(my_dict2),my_dict2)
# 定义非空字典
my_dict3={"name":"tom","age":24,"isman":True}
print(type(my_dict3),my_dict3)

# 修改与添加
# 1、将age改为20
my_dict3['age']=20
print(my_dict3)
# 2、新增一个height:170
my_dict3["height"]=170
print(my_dict3)

# 删除数据
# 删除height
my_dict3.pop("height")
print(my_dict3)
print('---------')

#查看字典中的数据
print(my_dict3["name"])# way-01
print(my_dict3.get("name"))#way-02
print(my_dict3.get("sex"))#键不存在则返回None
print('---------')
# 字典的遍历
# 一、遍历键和值
for key,value in my_dict3.items():
    print(key,value)
print('---------')
# 二、遍历键
# way-01
for key in my_dict3:
    print(key)
# way-02
for key in my_dict3.keys():
    print(key)
print('---------')
# 三、遍历值
for value in my_dict3.values():
    print(value)

